﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using VietStar.Library.Commom.Algorithm;
using VietStar.Library.Commom.Cryption;

namespace VietStar.Library.TestCode
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Converts cvt = new Converts();
                string inp = textBox1.Text;
                textBox2.Text = cvt.ConvertNumberToText(inp);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nhập số thôi con gà !");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Converts cvt = new Converts();
                string inp = textBox1.Text;
                textBox2.Text = cvt.ConvertMoneyToText(inp, "vnđ");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nhập số thôi con gà !");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Converts cvt = new Converts();
            string inp = textBox1.Text;
            textBox2.Text = cvt.ConvertToUnsign(inp);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            MD5Cryption crp = new MD5Cryption();
            string inp = textBox1.Text;
            textBox2.Text = crp.Encrypt(inp);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            RandomString rds = new RandomString();
            //string inp = textBox1.Text;
            textBox2.Text = rds.GenerateRandomString();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            try
            {
                RandomString rds = new RandomString();
                string inp = textBox1.Text;
                textBox2.Text = rds.GenerateRandomString(Int32.Parse(inp));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nhập số thôi con gà !");
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Validators vl = new Validators();
            string inp = textBox1.Text;
            textBox2.Text = vl.IsEmail(inp).ToString();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            Validators vl = new Validators();
            string inp = textBox1.Text;
            textBox2.Text = vl.IsNumeric(inp).ToString();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            Validators vl = new Validators();
            string inp = textBox1.Text;
            textBox2.Text = vl.IsImageFile(inp).ToString();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            Validators vl = new Validators();
            string inp = textBox1.Text;
            textBox2.Text = vl.IsDateTime(inp, false).ToString();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            Validators vl = new Validators();
            string inp = textBox1.Text;
            textBox2.Text = vl.IsDateTime(inp, true).ToString();
        }        
    }
}
